/*
* Copyright (c) 2007 by Kirill Kolodyazhniy.
* See the file "license.terms" for information on usage and redistribution.
*/

#ifndef M_ARCHIVE_H
#define M_ARCHIVE_H

#include "datastream.h"
#include "factory.h"
#include "refptr.h"

#include <string>
#include <vector>

namespace Engine
{
	/**
	*   Abstract class define interface for accessing to files in archives or file sytems folders.
	*/
	class Archive
	{
	public:
		typedef RefPtr<std::vector<std::string> > VectorStringPtr;

		/**
		*   Destructor.
		*/
		virtual ~Archive(){}

		/**
		*   Open file for reading;
		*   @param name files name;
		*/
		virtual RefPtr<DataStream> ReadFile(const std::string& name) const = 0;

		/** Find all file or directory names matching a given pattern in this archive.
		*   @param pattern The pattern to search for; wildcards (*) are allowed
		*   @param recursive Whether all paths of the archive are searched (if the archive has a concept of that)
		*   @param dirs Set to true if you want the directories to be listed instead of files
		*   @returns A list of filenames matching the criteria, all are fully qualified
		*/
		virtual VectorStringPtr Find(const std::string& pattern, bool recursive = true, bool dirs = false)const = 0;
	};

	/**
	*   Base class for all factories for archives.
	*/
	class ArchiveFactory: public Factory<Archive>
	{
	};
}

#endif

